---
description: "Reference for Nitric's v0 Node.js library - Fetch paged results from a query."
---

# Node.js - collection.query.fetch()

Retrieve a page of results for a query. This is an alternative to [collection.query.stream()](./collection-query-stream)

```javascript
import { collection } from '@nitric/sdk'

const profiles = collection('profiles').for('reading')

const profileQuery = profiles.query()

const results = await profileQuery.fetch()
```

## Examples

### Paging through results from a query

```javascript
import { collection } from '@nitric/sdk'

const profiles = collection('profiles').for('reading')

const profileQuery = profiles.query()

let results = await profileQuery.fetch()

do {
  for (const doc of results.documents()) {
    // Do something with the document
    console.log(doc)
  }

  if (pagingToken) {
    profileQuery.pagingFrom(pagingToken)
    results = await profileQuery.fetch()
  }
} while (results.documents().length > 0 || results.pagingToken)
```

### See also

- [query().where()](./collection-query-where)
- [query().limit()](./collection-query-limit)
- [query().pagingFrom()](./collection-query-pagingfrom)
